import { InitModalMethod, ParseModalMethod } from './defination';

/**
 * 设置表单属性
 * @param { Object } form 表单数据
 * @param { Object } workstep cached的ai工作流
 */
export const initModalData = (form = {}, workstep = {}) => {
	if (!form || !workstep || !workstep.do) {
		return;
	}
	// reason
	form.hangupReason = workstep.do?.data?.reason;
	// isCompleted
	form.isCompleted = workstep.isCompleted;

	form.name = workstep.name;
};
InitModalMethod['hangup'] = initModalData;

/**
 * 解析表单属性
 * @param { Object } form 表单数据
 * @param { Object } workstep cached的ai工作流
 */
export const parseModalData = (form = {}, workstep = {}) => {
	console.log(form, workstep);
	if (!form || !workstep || !workstep.do) {
		return;
	}
	// reason
	workstep.do.data.reason = form.hangupReason;
	// isCompleted
	workstep.isCompleted = form.isCompleted;

	workstep.name = form.name;
};
ParseModalMethod['hangup'] = parseModalData;
// {
//     "robotProperty": {
//         "needHearing": "preorder",
//         "videoType": "preorder",
//         "audioType": "preorder"
//     },
//     "name": "",
//     "do": {
//         "data": {
//             "reason": "1"
//         },
//         "command": "hangup"
//     },
//     "type": "sendMessage",
//     "no": "hangup_108",
//     "id": "hangup_108",
//     "isEnd": "true",
//     "isCompleted": true,
//     "completed": true,
//     "hasStartNode": false
// }
